import Vue from "vue";
import Router from "vue-router";
import Login from "@/views/login.vue";
import Home from "@/views/Home.vue";
import Home2 from "@/views/Home2.vue";
import Area from "@/views/dormitory/Area.vue";
import Floor from "@/views/dormitory/Floor.vue";
import Room from "@/views/dormitory/Room.vue";
import RoomInitialization from "@/views/dormitory/RoomInitialization.vue";
import Bed from "@/views/dormitory/Bed.vue";
import Checkin from "@/views/stay/Checkin.vue";
import Record from "@/views/stay/Record.vue";
import Retreat from "@/views/stay/Retreat.vue";
import UseGoods from "@/views/goods/UseGoods";
import RoomGoods from "@/views/goods/RoomGoods";
import GoodsInitialition from "@/views/goods/GoodsInitialition";
// import FreeCost from "@/views/cost/FreeCost";
// import OutCost from "@/views/cost/OutCost";
// import CostDetail from "@/views/cost/CostDetail";
// import MonthCost from "@/views/cost/MonthCost";
Vue.use(Router);

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default new Router({
  routes: [{
      path: "/",
      redirect: "/login",
      hidden: true
    },
    {
      path: "/login",
      name: "login",
      component: Login,
      hidden: true
    },
    {
      path: "/home",
      name: "导航首页",
      component: Home2,
      iconCls: "", //图标样式class
    },
    {
      path: "/home",
      name: "宿舍楼管理",
      component: Home,
      iconCls: "", //图标样式class
      children: [{
          path: "/area",
          component: Area,
          name: "区域管理",
          meta: {
            roles: ["IT00052"]
          }
        },
        {
          path: "/floor",
          component: Floor,
          name: "宿舍楼信息管理"
        },
        {
          path: "/roomInitialization",
          component: RoomInitialization,
          name: "房间初始化"
        },
        {
          path: "/room",
          component: Room,
          name: "房间管理"
        },
        {
          path: "/bed",
          component: Bed,
          name: "床位管理"
        }
      ]
    },
    {
      path: "/home",
      name: "入住/退宿",
      component: Home,
      iconCls: "",
      children: [{
          path: "/checkin",
          component: Checkin,
          name: "入住"
        },
        {
          path: "/retreat",
          component: Retreat,
          name: "退宿"
        },
        {
          path: "/record",
          component: Record,
          name: "入住退宿记录查询"
        }
      ]
    },
    {
      path: "/home",
      name: "物品管理",
      component: Home,
      iconCls: "",
      children: [{
          path: "/goodsinitialition",
          component: GoodsInitialition,
          name: "房间资产初始化"
        },
        {
          path: "/roomgoods",
          component: RoomGoods,
          name: "房间物品管理"
        },
        {
          path: "/usegoods",
          component: UseGoods,
          name: "领用物品管理"
        }
      ]
    }
    // {
    //   path: "/home",
    //   name: "费用管理",
    //   component: Home,
    //   iconCls: "", //图标样式class
    //   children: [
    //     {
    //       path: "/freecost",
    //       component: FreeCost,
    //       name: "免扣水电申请" // 申请单录入、查询、销假单录入、查询同一个界面
    //     },
    //     {
    //       path: "/costdetail",
    //       component: CostDetail,
    //       name: "水电费查询"
    //     },
    //     {
    //       path: "/outcost",
    //       component: OutCost,
    //       name: "退宿费用结算"
    //     },
    //     {
    //       path: "/monthCost",
    //       component: MonthCost,
    //       name: "月底结算"
    //     }
    //   ]
    // }
  ]
});
